<?php
global $_RQ,$_AR;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
$return=array();
$setting=$this->plugin_setting('setting');
if($_RQ['op']=='main'){

	$setting['tcommission1']=$setting['tcommission1']?$setting['tcommission1']:'分销佣金';
	$setting['tcommission']=$setting['tcommission']?$setting['tcommission']:'佣金';
	$setting['tcommission_detail']=$setting['tcommission_detail']?$setting['tcommission_detail']:'提现明细';
	$setting['tcommission_apply']=$setting['tcommission_apply']?$setting['tcommission_apply']:'已申请佣金';
	$setting['tcommission_wait']=$setting['tcommission_wait']?$setting['tcommission_wait']:'待收货佣金';
	$setting['tcommission_check']=$setting['tcommission_check']?$setting['tcommission_check']:'待打款佣金';
	$setting['tcommission_ok']=$setting['tcommission_ok']?$setting['tcommission_ok']:'可提现佣金';
	$setting['tcommission_fail']=$setting['tcommission_fail']?$setting['tcommission_fail']:'无效佣金';
	$setting['tcommission_lock']=$setting['tcommission_lock']?$setting['tcommission_lock']:'未结算佣金';
	$setting['tcommission_pay']=$setting['tcommission_pay']?$setting['tcommission_pay']:'成功提现佣金';
	$return['setting']=$setting;
	
	$detailcount=pdo_fetch('SELECT count(*) as total FROM '.tablename('jy_commission_tixian').' where mid='.$_SESSION['uid']);
	$tixian=pdo_fetch('SELECT SUM(commission) as total FROM '.tablename('jy_commission_tixian').' where status=1 and mid='.$_SESSION['uid']);
	$return['tixian']=$tixian['total']?$tixian['total']:0.00;
	$return['detailcount']=$detailcount['total'];
	$c1=pdo_fetch('SELECT SUM(commission1) as total FROM '.tablename('jy_commission_commission').' where agent1='.$_SESSION['uid']);
	$c2=pdo_fetch('SELECT SUM(commission2) as total FROM '.tablename('jy_commission_commission').' where agent2='.$_SESSION['uid']);
	$c3=pdo_fetch('SELECT SUM(commission3) as total FROM '.tablename('jy_commission_commission').' where agent3='.$_SESSION['uid']);
	$return['total']=$c1['total']+$c2['total']+$c3['total'];
	$a1=pdo_fetch('SELECT SUM(m.commission1) as total FROM '.tablename('jy_commission_commission'). ' as m  left join '.tablename('jy_weishop_order').' as o on o.id = m.orderid'.' where o.status=3 and  m.agent1='.$_SESSION['uid']);
	$a2=pdo_fetch('SELECT SUM(m.commission2) as total FROM '.tablename('jy_commission_commission'). ' as m  left join '.tablename('jy_weishop_order').' as o on o.id = m.orderid'.' where o.status=3 and m.agent2='.$_SESSION['uid']);
	$a3=pdo_fetch('SELECT SUM(m.commission3) as total FROM '.tablename('jy_commission_commission'). ' as m  left join '.tablename('jy_weishop_order').' as o on o.id = m.orderid'.' where o.status=3 and  m.agent3='.$_SESSION['uid']);
	$return['ok']=$a1['total']+$a2['total']+$a3['total'];
	
	$apply=pdo_fetch('SELECT SUM(commission) as total FROM '.tablename('jy_commission_tixian').' where status=1 and mid='.$_SESSION['uid']);
	$check=pdo_fetch('SELECT SUM(commission) as total FROM '.tablename('jy_commission_tixian').' where status=2 and mid='.$_SESSION['uid']);
	$fail=pdo_fetch('SELECT SUM(commission) as total FROM '.tablename('jy_commission_tixian').' where status=3 and mid='.$_SESSION['uid']);
	$pay=pdo_fetch('SELECT SUM(commission) as total FROM '.tablename('jy_commission_tixian').' where status=4 and  mid='.$_SESSION['uid']);
	$wait=pdo_fetch('SELECT SUM(commission) as total FROM '.tablename('jy_commission_tixian').' where status=5 and mid='.$_SESSION['uid']);
	$lock=pdo_fetch('SELECT SUM(commission) as total FROM '.tablename('jy_commission_tixian').' where status=6 and mid='.$_SESSION['uid']);
	$return['apply']=$apply['total']?$apply['total']:0;
	$return['check']=$check['total']?$check['total']:0;
	$return['fail']=$fail['total']?$fail['total']:0;
	$return['pay']=$pay['total']?$pay['total']:0;
	$return['wait']=$wait['total']?$wait['total']:0;
	$return['lock']=$lock['total']?$lock['total']:0;
	$return['ordercount']=$total['total'];
	exi($return);
}

?>